package test.h0816;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main3 {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        String[] split = sc.nextLine().split(",");
        //统计1的个数
        List<Integer> list=new ArrayList<>();
        int i=0;
        int count=0;
        for (String s : split) {
            if (s.equals("1")){
                count++;
            }else if (count>0){
                list.add(process(count));
                count=0;
            }
        }
        //处理最后一段
        if (count>0){
            list.add(process(count));
        }
        int sum = list.stream().mapToInt(Integer::intValue).sum();
        System.out.println(sum);
    }

    private static int process(int count) {
        int a = count / 3;
        int b=0;
        int temp1 = count % 3;
        if (temp1!=0){
             b= temp1/2;
        }
        int temp2=temp1%2;
        int c=0;
        if (temp2!=0){
            c=temp2;
        }
        return a+b+c;
    }
}
